package com.project.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.CustomerBean;
import com.project.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("customer")
public class CustomerController {
    @Autowired
    private ICustomerService service;
@RequestMapping("findByItem")
    public Page<CustomerBean> findByItem(Integer pageNo, String name, String ranges){
        return service.findByItem(pageNo,name,ranges);
    }
@RequestMapping("findById")
    public CustomerBean findById(Integer id){
    return service.findById(id);
    }
@RequestMapping("update")
    public String update(Integer id,String cadre,String phone,String range){
       service.update(id,cadre,phone,range);
       return "ok";
    }
@RequestMapping("add")
    public String add(String name, String cadre, String phone, String address, String ranges, String mailbox){
    CustomerBean customer = new CustomerBean(name,cadre,phone,address,ranges,mailbox);
    service.add(customer);
    return "ok";
    }
@RequestMapping("findAll")
    public List<CustomerBean> findAll(){
    return service.findAll();
    }
}
